<?php

class Zend_View_Helper_CkeditorHelper extends Zend_View_Helper_Abstract {

    function CkeditorHelper($textareaId,$option) {
        
        $op  = isset($option['height']) ? ' height:"'.$option['height'].'" ':'';
        $op .= $this->formatOp($option,'height');
        $op .= isset($option['width']) ? ' width:"'.$option['width'].'" ':'';
        
        return '<script type="text/javascript">CKEDITOR.replace ("'. $textareaId .'", { '.$op.' } );</script>';
    }
    
    function formatOp($str,$item){
        return isset($str[$item]) ? " , ":"";
    }
            
    function getCkeditor($name = null, $value = '', $width = '100%', $height = '300') {

        $CKEditor = new Ckeditor();

        $CKEditor->basePath = URL::base() . "media/js/ckeditor/";

        $CKEditor->config['width'] = $width;

        //$CKEditor->textareaAttributes = array("cols" => 80, "rows" => 10);

        $CKEditor->returnOutput = true;

        return $CKEditor->editor($name, $value);
    }

    function getCkeditorJs($textareaId) {
        return "<script type=\"text/javascript\">CKEDITOR.replace ( '" . $textareaId . "' );</script>";
    }

}
